package com.example.ercmssystem2.controller;

import com.example.ercmssystem2.entity.User;
import com.example.ercmssystem2.service.UserService;
import com.example.ercmssystem2.util.JwtUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/task-report")
@CrossOrigin(origins = "*")
public class TaskReportController {

    private final UserService userService;
    private final JwtUtil jwtUtil;

    @Autowired
    public TaskReportController(UserService userService, JwtUtil jwtUtil) {
        this.userService = userService;
        this.jwtUtil = jwtUtil;
    }

    // 页面路由 - 显示任务报告页面
    @GetMapping
    public String showTaskReportPage(@RequestParam(required = false) Long eventId, Model model) {
        // 暂时跳过后端认证检查，让前端处理认证
        // 这样可以避免JWT token在页面访问时无法正确设置Spring Security上下文的问题
        model.addAttribute("eventId", eventId);
        return "task-report";
    }

    // 页面路由 - 显示任务报告管理页面
    @GetMapping("/management")
    public String showTaskReportManagementPage(Model model) {
        // 暂时跳过后端认证检查，让前端处理认证
        model.addAttribute("title", "任务报告管理");
        return "task-report-management";
    }
} 